﻿using System;
using CoreTypes;
using System.Threading;
using System.Custom.Window;
using System.Windows.Forms;
using MainModule.Properties;

namespace MainModule
{
   internal partial class SplashScreen : Window
   {
      bool FDebugMode;// = true;

      internal SplashScreen()
      {
         InitializeComponent();

         labelVersion.Text = InternetCommunicator.VersionText;
      }

      private void Wait()
      {
         if (FDebugMode)
         {
            DateTime dt = DateTime.Now;
            while ((DateTime.Now - dt).TotalMilliseconds < 2000) try { Application.DoEvents(); Thread.Sleep(1); }
               catch { }
         }
         else
         {
            Application.DoEvents();
         }
      }

      internal void DoProgress(int value)
      {
         progressBar.Value = value;
         Wait();
      }

      internal void DoProgress(int value, string text)
      {
         labelProgress.Text = text;
         progressBar.Value = value;
         Wait();
      }

      private void splashScreen_Paint(object sender, PaintEventArgs e)
      {
         InternetCommunicator.Self.DrawTheme(ColorTheme.Citron, e.Graphics, (sender as Control).ClientRectangle, ColorThemeObject.Pattern);
      }
   }
}
